import logging

# 配置日志
import sys

from mq.kafka.DfcfStockKafkaConsumer import DfcfStockKafkaConsumer

logging.basicConfig(
    format='%(asctime)s.%(msecs)03d [%(levelname)s] %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
    level=logging.INFO
)
logger = logging.getLogger(__name__)
# Kafka消费者配置
config = {
    # 'bootstrap.servers': '39.98.82.109:29092,39.98.82.109:39092',  # Kafka服务器地址
    'bootstrap.servers': '192.168.0.110:9092',
    'group.id': 'python-consumer-group-9',    # 消费者组ID
     'auto.offset.reset': 'earliest',
    # 'auto.offset.reset': 'latest',
    'enable.auto.commit': True,             # 自动提交偏移量
}

# 要订阅的主题
topics = ['dfcf_stock_topic_2']
try:
    consumer = DfcfStockKafkaConsumer(config, topics, None , None , 0,None)
    consumer.subscribe_to_topics()
    consumer.group_consume_messages()
except Exception as e:
    logger.error(f"消费者发生错误: {e}")
    sys.exit(1)
